//
//  TeacherHomepageVC.m
//  teaching
//
//  Created by yishangpin2 on 15/5/7.
//  Copyright (c) 2015年 衣尚品1. All rights reserved.
//

#import "TeacherHomepageVC.h"
#import "HomePageView.h"
#import "AppDelegate.h"

@interface TeacherHomepageVC ()
@property (weak, nonatomic) IBOutlet UIButton *HongButton;
@property (weak, nonatomic) IBOutlet UIButton *ZuiXinButton;
@property (weak, nonatomic) IBOutlet UIButton *TuiJianButton;
@property (weak, nonatomic) IBOutlet UIButton *FenLeiButton;
@property (weak, nonatomic) IBOutlet UIButton *XueShiButton;
//@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Height;
//@property (weak, nonatomic) IBOutlet NSLayoutConstraint *Width;
@end

@implementation TeacherHomepageVC

{
    NSTimer *timer;
    AppDelegate *delegate;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.HongButton.layer.cornerRadius=25.0;
    self.HongButton.layer.masksToBounds=YES;
    self.ZuiXinButton.layer.cornerRadius=25.0;
    self.ZuiXinButton.layer.masksToBounds=YES;
    self.TuiJianButton.layer.cornerRadius=25.0;
    self.TuiJianButton.layer.masksToBounds=YES;
    self.FenLeiButton.layer.cornerRadius=10.0;
    self.FenLeiButton.layer.masksToBounds=YES;
    self.XueShiButton.layer.cornerRadius=10.0;
    self.XueShiButton.layer.masksToBounds=YES;
    
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"HomePageView" owner:self options:nil];
    HomePageView *homepageview= nib[0];
    homepageview.frame = CGRectMake(0, 455, 320, 922);
    
    [self.scrollview addSubview:homepageview];
    self.scrollview.contentSize = CGSizeMake(320, homepageview.frame.size.height + 455);
    
    
    delegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];
    delegate.HomePage = self;
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    
//    self.Height.constant = 30;
    //    self.Height1.constant = 45;
    [UIView animateWithDuration:1.0 animations:^{
        [self.view layoutIfNeeded];
    }];
//    
//    timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(animatechange) userInfo:nil repeats:YES];
}

- (void)viewDidDisappear:(BOOL)animated{
    
    [timer invalidate];
}

//- (void)animatechange{
//    if (self.Height.constant == 17) {
//        self.Height.constant = 8;
//        self.Width.constant = 2;
//    }
//    else
//    {
//        self.Height.constant = 17;
//        self.Width.constant = 18;
//    }
//    //    self.Height1.constant = 45;
//    [UIView animateWithDuration:1.0 animations:^{
//        [self.view layoutIfNeeded];
//    }];
//    
//    
//}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

//- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
//    self.Height.constant = 30;
//    //    self.Height1.constant = 45;
//    [UIView animateWithDuration:1.0 animations:^{
//        [self.view layoutIfNeeded];
//    }];
//    
//}

- (IBAction)Change_Identity:(id)sender {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil message:@"是否切换到学生端" delegate:self cancelButtonTitle:@"否" otherButtonTitles:@"是", nil];
    [alert show];
 
}


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 0) {
        NSLog(@"否");
        
    }
    else
    {
        NSLog(@"是");
        
        UITabBarController *tabbar = [self.storyboard instantiateViewControllerWithIdentifier:@"xuesheng"];
        [self presentViewController:tabbar animated:YES completion:nil];
    }

}
@end
